package com.aijia.custom.product.utils;

import com.aijia.custom.product.data.SheetData;

import java.util.LinkedList;

/**
 * Created by yejianjun on 2019/4/26.
 */

public class AddOrderHelper {

    private static LinkedList<IDataChangerListener> mListener;
    private static AddOrderHelper instance;

    public static AddOrderHelper getInstance() {
        if (null == mListener) {
            mListener = new LinkedList<>();
            instance = new AddOrderHelper();
        }
        return instance;
    }

    public interface IDataChangerListener {
        void refreshDate();

        void updateInfo(SheetData data);
    }

    public void addListener(IDataChangerListener listener) {
        mListener.add(listener);
    }

    public void removeListener(IDataChangerListener listener) {
        mListener.remove(listener);
    }

    public void refreshDate() {
        for (int i = 0; i < mListener.size(); i++) {
            mListener.get(i).refreshDate();
        }
    }

    public void updateInfo(SheetData data) {
        for (int i = 0; i < mListener.size(); i++) {
            mListener.get(i).updateInfo(data);
        }
    }

}
